package com.intel.two.listener.community;

import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import com.intel.two.bo.community.SecurityBo;
import com.intel.two.pojo.community.Security;
import com.intel.two.service.community.SecurityService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

@Component
@Scope("prototype")
public class WebSecurityListener extends AnalysisEventListener<SecurityBo> {
    @Autowired
    private SecurityService securityService;
    @Override
    public void invoke(SecurityBo data, AnalysisContext context) {
        System.out.println(data);
        Security security = new Security();
        BeanUtils.copyProperties(data,security);
        securityService.addSecurity(security);

    }

    @Override
    public void doAfterAllAnalysed(AnalysisContext context) {

    }
}
